﻿using System;

namespace diantou.web.enterprise
{
    /// <summary>
    /// OJ题目
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPage = false, IsPool = true)]
    partial class problemDescription : examPermissionView<problemDescription>
    {
        /// <summary>
        /// 题目
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private diantou.examDataAccess.examProblem problem;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="problemId"></param>
        /// <returns></returns>
        protected bool loadView(int problemId)
        {
            problem = diantou.examDataAccess.clientCache.ExamProblem[problemId];
            if (problem != null)
            {
                if (problem.EnterpriseId == currentUser.Id || currentUser.Permission == dataModel.user.permission.Admin) return true;
                if (currentEnterprise.IsEnterprisePermissionValidity)
                {
                    if ((problem.ShowType == dataModel.problemBase.showType.Show || problem.ShowType == dataModel.problemBase.showType.Expired) && !problem.IsPrivate)
                    {
                        return true;
                    }
                }
                problem = null;
            }
            AjaxResponse(new fastCSharp.code.cSharp.webView.errorPath { ErrorPath = diantou.dataModel.path.pub.EnterpriseLogin });
            return false;
        }
    }
}
